<section class="content-header">
  <h1>Job details
    <a ui-sref="main.jobs" class="pull-right">
      <small class="text-primary">
        <i class="fa fa-chevron-left fa-lg"></i> Back to list</small>
    </a>
  </h1>
</section>
<!-- Main content -->
<section class="content">
  <div class="row">
    <div class="col-md-3">
      <job-details job="$ctrl.job"></job-details>
    </div>
    <div class="col-md-9">
      <div class="box box-primary job-box">
        <div class="box-header">
          <h3 class="box-title">Job report</h3>
        </div>
        <div class="box-body job-report">
          <h5 class="text-primary">Parameters</h5>
          <pre>{{$ctrl.job.parameters | json}}</pre>
          
          <div ng-if="$ctrl.job.type === 'responder'">
            <h5 class="text-primary">Input details</h5>
            <pre>{{$ctrl.job.data | json}}</pre>
          </div>

          <div>
            <h5 class="text-primary mt-xs">Report</h5>
            <pre>{{$ctrl.job.report | json}}</pre>
          </div>

          <div ng-if="$ctrl.job.report.artifacts.length > 0">
            <h5 class="text-primary mt-xs">Artifacts</h5>
            <div class="mv-xxs" ng-if="$ctrl.hasFileArtifact">
              <small class="text-danger">Zip are protected with password "{{$ctrl.protectDownloadsWith}}"</small>
            </div>
            <table class="table table-striped">
              <tr>
                <th width="20">#</th>
                <th width="100">Datatype</th>
                <th>Value</th>
              </tr>
              <tr ng-repeat="artifact in $ctrl.job.report.artifacts track by $index">
                <td>{{$index + 1}}</td>
                <td>{{artifact.dataType}}</td>
                <td>
                  <div class="wrap" ng-if="artifact.dataType === 'file'">
                    {{artifact.attachment.name| fang}}
                    <a href="./api/datastorezip/{{artifact.attachment.id}}?name={{artifact.attachment.name}}"
                      target="_blank">
                      (Download)
                    </a>
                  </div>
                  <div class="wrap" ng-if="artifact.dataType !== 'file'">
                    {{artifact.data | fang}}
                  </div>
                  <div ng-if="artifact.tags.length > 0">
                    <span class="label label-primary"
                      ng-repeat="tag in artifact.tags track by $index">{{tag.text}}</span>&nbsp;
                  </div>
                </td>
              </tr>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>